package com.example.demo.mapper;

import com.example.demo.model.Student;
import com.example.demo.model.Teacher;
import org.apache.ibatis.annotations.*;
import org.springframework.data.domain.Example;

import java.util.List;

@Mapper
public interface TeacherMapper {
    @Select("select * from teacher")//不符合JPA的规范
    List<Teacher> findAll();

    @Select("select * from teacher where tel = #{tel}")//占位符：#{参数名}；参数名定义标识与String定义的相同
    List<Teacher> findByTel(String tel);

    @Select("select * from teacher where id = #{id}")
    Teacher get(int id);

    @Delete("delete from teacher where id = #{id}")
    void delete(Integer id);

    @Insert("insert into teacher(id, name, tel, age) values(#{id}, #{name}, #{tel}, #{age})")
    void save(Teacher teacher);

    @Update("update teacher set name = #{name}, age = #{age}, tel = #{tel} where id = #{id}")
    void update(Teacher teacher);

    //@Select("select * from teacher where name = #{name} and tel = #{tel}")
    List<Teacher> search(Teacher teacher);

    //Teacher getReferenceById(Integer id);

    //<T> List<Teacher> findAll(Example<T> of);
}
